﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FrameWork.Plugin;
using FrameWork.Setting;
using FrameWork.Log;
using System.Reflection;
using System.Runtime.InteropServices;
using System.ComponentModel;
using FrameWork.Output;
using System.Windows.Forms;
using ScreenMonitor.ServerLib.Plugin;
using System.ServiceModel;

namespace WcfSupportPlugin
{
    [SettingParentDefine]
    public class WcfSupportPlugin : LogableClassBase, IServerPlugin
    {
        /// <summary>
        /// 基址
        /// </summary>
        [SettingItemDefine(SettingValueType.String,"http://localhost:8306")]
        [DisplayName("基址")]
        [Description("表示承载Wcf服务的服务器基址")]
        [Browsable(true)]
        [DefaultValue("http://localhost:8306")]
        public String BaseAddress { get; set; }

        public string GetPluginName()
        {
            return "WcfSupportPlugin";
        }

        public Guid GetPluginGuid()
        {
            return new Guid("23BC6FE7-7789-461F-95F2-A4443BD950AB");
        }

        public string GetPluginDescription()
        {
            return "Wcf支持插件";
        }

        public List<FrameWork.Setting.SettingEditorItem> GetSettingEditors()
        {
            List<SettingEditorItem> EditorList = new List<SettingEditorItem>();
            EditorList.Add(new SettingPropertyEditorItem(@"Wcf\常规", this, this.GetType()));
            return EditorList;
        }

        public System.Windows.Forms.Form GetPluginWindow()
        {
            return PluginObjects.PluginWnd;
        }

        public IEnumerable<FrameWork.Output.OutputCollectorBase> GetOutputCollectors()
        {
            List<OutputCollectorBase> List = new List<OutputCollectorBase>();
            List.Add(PluginObjects.WcfSupportPluginOutputCollector);
            return List;
        }

        public bool Enable()
        {
            base.PrintLog(LogType.Info, "Wcf服务插件已启用！");
            return true;
        }

        public bool Disable()
        {
            base.PrintLog(LogType.Info, "Wcf服务插件已禁用！");
            return true;
        }

        public bool Init()
        {
            base.PrintLog(LogType.Info, "Wcf服务初始化...");
            return true;
        }


        public void SetMenu(System.Windows.Forms.MenuStrip MainMenuStrip)
        {
            ToolStripItem[] MenuItems = MainMenuStrip.Items.Find("ManagerMenu", false);
            if (MenuItems.Count() > 0)
            {
                ToolStripDropDownItem ToolsMenu = (ToolStripDropDownItem)MenuItems[0];
                ToolsMenu.DropDownItems.Add(PluginObjects.PluginWnd.toolsWcfControl);
            }
        }

        public List<string> GetCommands()
        {
            return new List<string>();
        }

        public void RunCommand(string Command, byte[] Data)
        {
            return;
        }
    }
}
